package com.tianyi.sfzy1.controller;

import com.tianyi.sfzy1.domain.Coursequestion;
import com.tianyi.sfzy1.service.CoursequestionService;
import com.tianyi.sfzy1.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/coursequestion")
public class CoursequestionController {
    @Autowired
    private CoursequestionService coursequestionService;
    //查询所有
    @GetMapping
    private R findAll(){
        return R.ok(coursequestionService.findAll());
    }
    @GetMapping("/id")
    //根据id查询
    private R selectByPrimaryKey(int questionId){
        return R.ok(coursequestionService.selectByPrimaryKey(questionId));
    }

    //查询课程表,课程问题表,咨询表
    @GetMapping("/ccocq")
    private R selectCourseQuestionConsultant(){
        //打印结果
        System.out.println(coursequestionService.selectCourseQuestionConsultant());
        return R.ok(coursequestionService.selectCourseQuestionConsultant());
    }

    @PostMapping
    //新增
    private R insert(@RequestBody Coursequestion record){
        System.out.println(record);
        return R.ok(coursequestionService.insert(record));
    }
    @PutMapping
    //修改全部字段
    private R updateByPrimaryKey(Coursequestion record) {
        return R.ok(coursequestionService.updateByPrimaryKey(record));
    }

    //删除
    @DeleteMapping
    private R deleteByPrimaryKey(int questionId){
        return R.ok(coursequestionService.deleteByPrimaryKey(questionId));
    }

}
